/*
 * LogService.java
 * Copyright (c) 2014, 2019, Kiri. 
 * All rights reserved.
 */
package com.onesalt.service;

import java.util.Date;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.onesalt.domain.system.SysLog;

/**
 * 
 *
 * @author kiri
 * @date 2015年5月17日
 * @version 1.0
 */
@Service
@Transactional
public class LogService extends AbstractService {

	private static final String SYSLOG_PLATFORM_BACKEND = "backend";
	
	private final SysLogRepository sysLogRepository;
	
	@Autowired
	public LogService(SysLogRepository sysLogRepository) {
		this.sysLogRepository = sysLogRepository;
	}

	public SysLogRepository getSysLogRepository() {
		return sysLogRepository;
	}
	
	public void log(String message) {
		getLogger().debug(message);
		SysLog log = new SysLog();
		log.setTime(new Date());
		log.setPlatform(SYSLOG_PLATFORM_BACKEND);
		getSysLogRepository().save(log);
	}
}
